import { s_getcommontableinfo, s_getPurchaseInfo, status2text } from "@/services/basis";
import { ProCard, ProColumns, ProTable } from "@ant-design/pro-components";
import { Button, Space, Tag ,Image} from "antd";
import { useState } from "react";

const App:React.FC=()=>{
    const [total,setTotal]=useState(0);
    interface DataType{
//         x_id,org_id,vouch_code,vendor_id,vouch_status,operate_time,
// material_id,userdefine_name,quantity,deliverdate,
// code,name,invstd,invstd2,munit_name,
// org_name,vendor_name,operater_name,
// quantity_deliver,quantity_reback,quantity_stockin,progress_stockin
x_id?:number,vouch_code?:string,vendor_id?:number,operate_time?:string,
material_id?:number,quantity?:number,stockin_time1?:string,stockin_time2?:string,
code?:string,name?:string,invstd?:string, munit_name?:string,
 vendor_name?:string,operater_name?:string,warehouse_name?:string,
 price?:number,total?:number, 
    };

 const columns:ProColumns<DataType>[]=[
        {dataIndex:'pic',title:'图片' ,editable:false,search:false,width:80,
          //     render:(text)=>{
          //         var pic=text=="-"||text==undefined?"":"/basis_api/file/get?filename="+text;
          //         return <Image src={pic}  
          //                style={{width:50,height:50}} alt='无' />
          //    },
          //  },
             render:(text,record,index,k)=>{
                         var pic="/basis_api/file/get2?filename="+record.code;
                         return   <Image src={pic}  style={{width:50,height:50}} alt='无' />
          }},
        {dataIndex:'vouch_code',title:'入库单号' },
        {dataIndex:'vendor_name',title:'供应商' },
        {dataIndex:'code',title:'SKU编码',},
        {dataIndex:'name',title:'商品名称',width:'20%'},
        {dataIndex:'invstd',title:'包装规格',search:false,width:'20%'},
        // {dataIndex:'userdefine_name',title:'自定义项'},
        {dataIndex:'munit_name',title:'计量单位',search:false,},
        {dataIndex:'quantity',title:'入库数量',search:false,},
        {dataIndex:'price',title:'单价',search:false,},
        {dataIndex:'total',title:'金额',search:false,},
        {dataIndex:'operater_name',title:'入库人',search:false,},
        {dataIndex:'stockin_time1',title:'入库时间',valueType:'date',search:false},
        {dataIndex:'stockin_time1',title:'入库起始时间',hidden:true,valueType:'date'},
        {dataIndex:'stockin_time2',title:'入库截止时间',hidden:true,valueType:'date'},
         
    ];

    
    //==============================================================================================================
    return <>
      <ProCard title='采购入库明细表' style={{height:'85vh',overflow:'auto'}}
        //  extra={<Space>
        //     <Button>查看采购齐套</Button>
        //     <Button>查看入库明细</Button>
             
        //  </Space>}
      >
          <ProTable<DataType>
             columns={columns}
            //  dataSource={tdata}
             search={{span:4}}
            //  rowSelection={{
            //     type:'checkbox'
            //  }}
             rowKey='id'
             options={false}
            //   request={async ()=>{
            //     // x_id,cate_id,id,source,fdata
            //     const x=await s_getcommontableinfo({x_id:1,cate_id:[],id:0,source:'v_purchase_order_progress',fdata:null});
            //     return {
            //         data:x.data[0],
            //         success:true,
            //     }
            //  }}
              // v_sale_order_main
             request={async (param)=>{
                  const x=await s_getPurchaseInfo({source:'report_stock_in_purchase_detail',x_id:1,
                                               fdata:{id:0,param}});
                  setTotal(x.data[0][0].count);
                  return{
                         data:x.data[1],
                         success:true,
                         }
                 }}
            scroll={{y:'56vh'}}
                    pagination={{
                    showQuickJumper:true,
                    showSizeChanger:true,
                    defaultPageSize:10,
                    defaultCurrent:1,
                    total,
                  }}
          /> 
      </ProCard> 
    </>;
}

export default App;